<link href="css/eval.css" rel="stylesheet" type="text/css"/>
<style type="text/css">
	#star{position:relative;width:200px;margin:0px auto;height:24px;display: inline;}
	#star ul,#star span{float:left;display:inline;height:19px;line-height:19px;}
	#star ul{margin:0 10px;}
	#star li{float:left;width:24px;cursor:pointer;text-indent:-9999px;background:url(img/star.png) no-repeat;}
	#star strong{color:#f60;padding-left:10px;}
	#star li.on{background-position:0 -28px;}
</style>
<div class="menu-header">
</div>
<div class="menu-body">
</div>
<script id="eval_header" type="text/html">
	<div class="title">
		<i class='fa fa-comments fa-2x' style="margin-right: 10px"></i>用户评价
	</div>
      <select name="s1" onchange="getEval()">
		<ul>
   		 <li><option value="">全部主题</option></li>
		 {{each themelist as value index}}
		 <li><option value="{{value.themeId}}">{{value.themename}}</option></li>
		 {{/each}}
		</ul>
  	  </select>
  	  <select name="s2" onchange="getEval()">
		 <option value="0">所有</option>
   		 <option value="1">未回复</option>
		 <option value="2">已回复</option>
  	  </select>
  	  <select name="s3" onchange="getEval()">
   		 <option value="0">所有</option>
		 <option value="1">最近一周</option>
		 <option value="2">最近半个月</option>
		 <option value="3">最近一个月</option>
  	  </select>
	<div class="tools">
		<a class='btn' onclick="getEval()" title='刷新'>
			<i class='fa fa-rotate-left (alias) fa-2x'></i>
		</a>
	</div>
</script>
<script id="eval_tmpl" type="text/html">
<div class='panel panel-default grid' >
		<div id="evalDiv" style="overflow: hidden; width: auto; height:100%;padding:10px">
{{each list as value index}}
	<div class="itemdiv commentdiv">
		<div class="user">
			<img src="{{value.headimgurl}}" height="60" width="60">
		</div>
		<div class="body">
			<div class="name">
				<a href="#">{{value.username}}</a> 评价了主题： {{value.themename}}
			</div>
			<div class="time">
				<div id="star">
					<ul>
						<li class="{{if value.evalstar>=1}}on{{/if}}"><a href="javascript:;">1</a></li>
						<li class="{{if value.evalstar>=2}}on{{/if}}"><a href="javascript:;">2</a></li>
						<li class="{{if value.evalstar>=3}}on{{/if}}"><a href="javascript:;">3</a></li>
						<li class="{{if value.evalstar>=4}}on{{/if}}"><a href="javascript:;">4</a></li>
						<li class="{{if value.evalstar>=5}}on{{/if}}"><a href="javascript:;">5</a></li>
					</ul>
				</div>
				<i class="icon-time"></i>
				<span class="green">{{value.createdate}}</span>
			</div>
			<div class="text">
				<i class="icon-quote-left"></i>
				<label>{{value.content}}</label><br>
				<label class="{{if value.reply==''}}undisplay{{/if}}"> 商家回复：{{value.reply}}</label>
				<div class="input-group {{if value.reply!=''}}undisplay{{/if}}">
					<input id="{{value.id}}" type="text" class="form-control" placeholder="请输入回复内容！">
					<span class="input-group-btn">
						<button class="btn btn-default" type="button" onclick="replyClick({{value.id}})" >回复</button>
					</span>
				</div>
			</div>
		</div>
		</div>
		{{/each}}
	</div>
<div style="text-align:center;margin-top:0px;">
				{{each page as value index}}
		<ul class="pagination">
					<li><button onclick="getEval({{value.i}})">{{value.i}}</button></li>
		</ul>
				{{/each}}
		</div>
	</div>
</div>
</script>
<script type="text/javascript">	
getEval(1);
function getEval(page){
	 var para={
		page:page
	 };
	 if (document.getElementsByName("s1")[0]!= undefined) {
		 para.themeId = document.getElementsByName("s1")[0].value;
	 }
	 if (document.getElementsByName("s2")[0]!= undefined) {
		 para.reply = document.getElementsByName("s2")[0].value;
	 }
	 if (document.getElementsByName("s3")[0]!= undefined) {
		 para.time = document.getElementsByName("s3")[0].value;
	 }
	callSvr("eval/getEval",para, function(result){
		 var html=template('eval_tmpl',result);
		 $(".menu-body").html(html);
		 
	});
}
function header(){
	callSvr("eval/header",{}, function(result){
		var data={
			themelist:result
		}
		 var html=template('eval_header',data);
		 $(".menu-header").html(html);
	});
}
header();
function replyClick(evalId){
	var para = {reply:$("#" + evalId).val(),
				evalid:evalId
				};
	callSvr("eval/reply",para, function(result) {
			 toastr.success('回复成功！','');
			 getEval();
	});
}
</script>
